-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Use aria-disabled instead of disabled for undo/redo #11379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works! 👍
I'm wondering, should this logic exist in Button
and/or IconButton
? Does this bug also exist in other places where we're using buttons with the disabled
prop? It would be nice if developers could set the disabled
prop on our Button
component and rely on it doing the Right Thing™.
It probably should, but I tried that in the past with some other buttons (in the Datepicker's |
redo: () => dispatch( 'core/editor' ).redo(), | ||
withDispatch( ( dispatch, ownProps ) => ( { | ||
redo: () => { | ||
// If there are no redo levels this is a no-op, because we don't actually |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In treating EditorHistoryRedo
as the presentational component of the Presentational / Container pair, it seems like if it's meant to be a disabled behavior, it should be considered by the component in deciding to invoke the onClick
callback.
Even something like:
onClick={ hasRedo ? redo : undefined }
It's not so much a concern here in that the components are so tied to the specific editor use case of Undo/Redo, but is a good rule of thumb in delegating where logic should occur between the underlying component and its enhancer(s).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point. Follow-up PR with a fix is here: #11428.
* chore: Improve undo/redo no-op See: https://github.com/WordPress/gutenberg/pull/11379\#discussion_r230406108 * Do not wrap dispatch undo/redo
Fixes #3486
Description
Change the undo/redo buttons from using the
disabled
attribute and instead use thearia-disabled
attribute; this prevents focus loss when the undo/redo actions are unavailable.Note that there are no visual/functional differences here aside from screenreaders now announcing that the button becomes unavailable once disabled and focus is not lost as before.